#include <bits/stdc++.h>
using namespace std;
#define int long long
struct node{
    int d,v,a;
}c[100005];
int pos[100005];
bool cmp(pair<int,int>a,pair<int,int>b){
    return a.second<b.second;
}
int ckv(int d,int v,int a){
    return v*v+2ll*a*d;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int T;
    cin>>T;
    while(T--){
        int n,m,l,v;
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
        }
        for(int i=1;i<=m;i++){
            cin>>pos[i];
        }
        int ans1=0,ans2=m;
        vector<pair<int,int> >ve;
        ve.clear();
        for(int i=1;i<=n;i++){
            if(c[i].d>pos[m])continue;
            if(c[i].a==0){
                if(c[i].v>v){
                    ve.push_back({lower_bound(pos+1,pos+m+1,c[i].d)-pos,m});
                    ans1++;
                }
            }else if(c[i].a>0){
                int l=lower_bound(pos+1,pos+m+1,c[i].d)-pos,r=m,ans=r;
                int tr=r;
                if(ckv(pos[r]-c[i].d,c[i].v,c[i].a)<=v*v){
                    continue;
                }
                while(l<=r){
                    int mid=l+r>>1;
                    if(ckv(pos[mid]-c[i].d,c[i].v,c[i].a)<=v*v){
                        l=mid+1;
                    }else{
                        ans=mid;
                        r=mid-1;
                    }
                }
                ve.push_back({ans,tr});
                ans1++;
            }else{
                int l=lower_bound(pos+1,pos+m+1,c[i].d)-pos,r=m,ans=l;
                r=min(r,(int)(upper_bound(pos+1,pos+m+1,c[i].d+c[i].v*c[i].v/(2ll*(-c[i].a)))-pos-1));
                if(l>r)continue;
                int tl=l;
                if(ckv(pos[l]-c[i].d,c[i].v,c[i].a)<=v*v){
                    continue;
                }//v*v/-2a
                while(l<=r){
                    int mid=l+r>>1;
                    if(ckv(pos[mid]-c[i].d,c[i].v,c[i].a)<=v*v){
                        r=mid-1;
                    }else{
                        ans=mid;
                        l=mid+1;
                    }
                }
                ve.push_back({tl,ans});
                ans1++;
            }
        }
        sort(ve.begin(),ve.end(),cmp);
        int r=0;
        for(pair<int,int>a:ve){
            if(a.first>r){
                r=a.second;
                ans2--;
            }
        }
        cout<<ans1<<' '<<ans2<<'\n';
    }
}